package com.zhongkun.datahome.service.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongkun.datahome.service.domain.MaterialRoom;
import com.zhongkun.datahome.service.mapper.MaterialRoomMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/23 10:49
 * @Desc
 */
@Repository
public class MaterialRoomRepository extends ServiceImpl<MaterialRoomMapper, MaterialRoom> {
    public List<MaterialRoom> listBy(String relationType, Long relationId) {
        return this.list(new LambdaQueryWrapper<MaterialRoom>()
                .eq(MaterialRoom::getRelationType, relationType)
                .eq(MaterialRoom::getRelationId, relationId));
    }

    public void removeBy(String relationType, List<Long> ids) {
        this.remove(new LambdaQueryWrapper<MaterialRoom>()
                .eq(MaterialRoom::getRelationType, relationType)
                .in(MaterialRoom::getRelationId, ids));
    }
}
